// 引入reqeust,封装api接口函数,发送请求的
import request from '@/utils/request'
// 引入平台属性相关的类型
import type { AttrModel, AttrListModel } from './model/attrModel'
// 引入分类id相关的数据类型
import type { CategoryIdsModel} from './model/categoryModel'
// 定义枚举类型的api地址
enum Api { 
  GetAttrList='/admin/product/attrInfoList',
  DeleteAttrById='/admin/product/deleteAttr',
  AddOrUpdateAttr='/admin/product/saveAttrInfo',
}
// 根据三个分类的id获取平台属性对象数组数据
export const getAttrListApi = ({ category1Id, category2Id, category3Id }: CategoryIdsModel) => request.get<any, AttrListModel>(Api.GetAttrList + `/${category1Id}/${category2Id}/${category3Id}`)
// 根据平台属性的id删除平台属性对象数据
export const deleteAttrByIdApi=(attrId:number)=>request.delete<any,null>(Api.DeleteAttrById+`/${attrId}`)
// 添加或者修改平台属性对象,参数是平台属性对象
export const addOrUpdateAttrApi=(attr:AttrModel)=>request.post<any,null>(Api.AddOrUpdateAttr,attr)